Skip to content

[ACR] az acr cache create/update: Add --identity parameter to support using user-assigned managed identity for cache rules#33040

Merged
yanzhudd merged 6 commits intoAzure:devfrom
AntonioVT:acr-to-acr-managed-identity
Mar 27, 2026
Merged

[ACR] az acr cache create/update: Add --identity parameter to support using user-assigned managed identity for cache rules#33040
yanzhudd merged 6 commits intoAzure:devfrom
AntonioVT:acr-to-acr-managed-identity

Conversation

@AntonioVT
Copy link
Copy Markdown
Member

@AntonioVT AntonioVT commented Mar 24, 2026

Related command
az acr cache create
az acr cache update

Description
This PR adds managed identity support for Azure Container Registry cache rules as an alternative authentication method to credential sets. Users can now authenticate cache rules with upstream registries using user-assigned managed identities instead of storing credentials in Azure Key Vault.

Changes made

  • Added --identity parameter to az acr cache create and az acr cache update commands
  • Implemented parameter validation for ARM resource ID format
  • Added test coverage for managed identity scenarios
  • Updated help text and parameter descriptions

Testing Guide

Prerequisites: Create two ACR registries (source and target)
az acr create -n sourceregistry -g myResourceGroup --sku Standard -l eastus
az acr create -n targetregistry -g myResourceGroup --sku Standard -l eastus

Import a test image to the source registry
az acr import -n sourceregistry --source mcr.microsoft.com/dotnet/runtime-deps:8.0

Create a user-assigned managed identity
az identity create -n cache-identity -g myResourceGroup -l eastus

Get the identity resource ID
IDENTITY_ID=$(az identity show -n cache-identity -g myResourceGroup --query id -o tsv)

Create cache rule with managed identity
az acr cache create -r targetregistry -n dotnet-cache -s sourceregistry.azurecr.io/dotnet/runtime-deps -t dotnet-runtime-deps --identity $IDENTITY_ID

Update cache rule to use different managed identity
az identity create -n cache-identity2 -g myResourceGroup -l eastus
IDENTITY_ID2=$(az identity show -n cache-identity2 -g myResourceGroup --query id -o tsv)

az acr cache update -r targetregistry -n dotnet-cache --identity $IDENTITY_ID2


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings March 24, 2026 16:29
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @AntonioVT,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Mar 24, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Mar 24, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️acr
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd acr cache create cmd acr cache create added parameter identity
⚠️ 1006 - ParaAdd acr cache update cmd acr cache update added parameter identity

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Mar 24, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@AntonioVT
Copy link
Copy Markdown
Member Author

AntonioVT commented Mar 24, 2026

Need to wait for #33017 getting merged, rebase and update.
#33017 has been merged

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds user-assigned managed identity support to az acr cache create / az acr cache update so cache rules can authenticate to upstream registries without credential sets, and updates the ACR SDK/API version and tests to support the new capability.

Changes:

  • Add --identity support for ACR cache rule create/update and wire it into request models.
  • Introduce validation for user-assigned identity ARM IDs and add live test + recording coverage.
  • Bump azure-mgmt-containerregistry and move ACR cache rules to 2026-01-01-preview API version (including profile updates).

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/azure-cli/setup.py Bumps azure-mgmt-containerregistry version to support new cache rule identity fields.
src/azure-cli/azure/cli/command_modules/acr/cache.py Adds identity support to cache create/update request payloads via SDK models.
src/azure-cli/azure/cli/command_modules/acr/_validators.py Adds validation for cache credential option combinations and identity ARM ID format.
src/azure-cli/azure/cli/command_modules/acr/_params.py Exposes --identity and hooks validation into argument parsing.
src/azure-cli/azure/cli/command_modules/acr/_constants.py Adds a template used to display identity ARM ID format examples.
src/azure-cli/azure/cli/command_modules/acr/_client_factory.py Switches cache rules client to 2026-01-01-preview.
src/azure-cli-core/azure/cli/core/profiles/_shared.py Updates ACR cache rules default API version and adjusts API version resolution behavior.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py Adds a managed identity live test for cache rules.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/recordings/test_acr_cache_managed_identity.yaml Adds the recording for the new managed identity scenario test.
src/azure-cli/HISTORY.rst Documents the new --identity parameter in release history.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@a0x1ab a0x1ab requested a review from a team March 25, 2026 06:23
@AntonioVT AntonioVT force-pushed the acr-to-acr-managed-identity branch from 67d8388 to 655720e Compare March 26, 2026 03:08
@AntonioVT
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 33040 in repo Azure/azure-cli

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

AntonioVT and others added 5 commits March 26, 2026 16:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Fix trailing whitespace in cache.py and _validators.py
- Break long lines to stay under 120 char limit
- Add pylint disable for unused-argument on acr_cache_update_get
- Add re.IGNORECASE flag to identity resource ID regex match

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AntonioVT AntonioVT force-pushed the acr-to-acr-managed-identity branch from 882071d to c192891 Compare March 26, 2026 23:45
@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@CodeJourneys CodeJourneys self-requested a review March 27, 2026 00:33
Copy link
Copy Markdown
Contributor

@CodeJourneys CodeJourneys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@northtyphoon northtyphoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

yanzhudd
yanzhudd previously approved these changes Mar 27, 2026
@yanzhudd yanzhudd changed the title {ACR} Add managed identity support to cache rule create/update commands [ACR] az acr cache create/update: Add --identity parameter to support using user-assigned managed identity for cache rules Mar 27, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd yanzhudd merged commit d6e3aba into Azure:dev Mar 27, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-identity-squad Auto-Assign Auto assign by bot Managed Identity For `az identity` only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants